import { useState } from "react"

// 定义基础设备状态接口
interface BaseDeviceState {
  isOnline: boolean
  isRun: boolean
  isRs: boolean
}

// 定义各个设备状态接口
interface DeviceState {
  camZmcState: BaseDeviceState
  cbjZmcState: BaseDeviceState
  cutterZmcState: BaseDeviceState
  cameraGrouupState: boolean[]
  orderUsedKey: string
}

export default function deviceModel() {
  const [deviceState, setDeviceState] = useState<DeviceState>({
    camZmcState: { isOnline: false, isRun: false, isRs: false },
    cbjZmcState: { isOnline: false, isRun: false, isRs: false },
    cutterZmcState: { isOnline: false, isRun: false, isRs: false },
    cameraGrouupState: [false, false, false, false, false],
    orderUsedKey: "1"
  })
  const updateDeviceState = (newState: Partial<DeviceState>) => {
    setDeviceState((prevState) => ({ ...prevState, ...newState }))
  }
  return { deviceState, updateDeviceState }
}
